#!/bin/bash
menu(){
	echo -e "\e[34m@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\e[0m"
	echo -e "\e[32m@  	1.add 加法运算\e[0m"
	echo -e "\e[33m@  	2.minus 减法运算\e[0m"
	echo -e "\e[34m@  	3.multiplication 乘法运算\e[0m"
	echo -e "\e[35m@  	4.division 除法运算\e[0m"
	echo -e "\e[36m@  	5.compare 比较数值大小\e[0m"
	echo -e "\e[32m@  	6.exit\e[0m"
	echo -e "\e[34m@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\e[0m"
}
#1.add
add(){
	read -p "please input two number: " num1 num2
	a=$(echo "scale=2;$num1 + $num2"|bc)
	echo "$num1 + $num2 = $a"
}
#2.minus
minus(){
	read -p "please input two number: " num1 num2
        a=$(echo "scale=2;$num1 - $num2"|bc)
        echo "$num1 - $num2 = $a"
}
#3.multiplication
multiplication(){
	read -p "please input two number: " num1 num2
        a=$(echo "scale=2;$num1 * $num2"|bc)
        echo "$num1 * $num2 = $a"
}
#4.division
division(){
	read -p "please input two number: " num1 num2
        a=$(printf "%.2f" `echo "scale=2;$num1/$num2"|bc`)
        echo "$num1/$num2 = $a"
}
#5.compare
compare(){
	read -p "please input two number: " num1 num2
        eq=`echo "$num1 - $num2"|bc`
        if [[ $eq == 0 ]]
        then
                echo "$num1=$num2"
        exit
        fi
        result=`echo "$num1>$num2"|bc`
        if (( result == 0 ))
        then
                echo "$num1 < $num2"
        else
                echo "$num1 > $num2"
        fi
}
#6.exit
main(){
  clear
  while true 
  do
  menu
  read -p " please choose the option(1-6): " choice
  case $choice in
  1)
        add
	;;
  2)
	minus
	;;
  3)
	multiplication
	;;
  4)
	division
	;;
  5)    
	compare
	;;
  6)
	break
	;;
  *)    break
	;;
 
  esac
   read -n 1 -p "please put any key to continue:" key
   clear 
  done
}
main
